<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/23 0023
 * Time: 11:07
 * 黄河
 */

namespace app\api\controller;

use app\admin\model\Baners;
use app\admin\model\Partynews;
use app\admin\model\Navigation;

/**
 * 党建要闻首页
 */
class PartyHomeFrame extends BaseController
{
    /**
     * 党建首页接口
     */
    public function getPartyHomeFrame()
    {
        $where = [
            'site' => 2,
            'status' => 1
        ];
        $where2 = [
            'a.status' => 1
        ];
        $fields = 'id ,site ,sort ,link_type, imgUrl, createDate';
        $Baners = Baners::where($where)->field($fields)->order('sort asc')->limit(0,4)->select();

        $fields = "a.id,a.title,a.imgUrl,a.createDate,d.name";
        $partynews = Partynews::where($where2)
            ->alias('a')
            ->join('user u','a.create_user_id = u.id')
            ->join('department d','u.departmentId = d.id')
            ->limit(0, 5)
            ->order('createDate desc')
            ->field($fields)
            ->select();



        $data['navigation'] = Navigation::where(['type'=>2,'is_del'=>0])->field('id as navId,name,imgUrl,link')->select();
        $data['baners'] = $Baners;
        $data['partynews'] = $partynews;

        return show(config('status.SUCCESS_STATUS'),'ok',$data);
    }


}